https://leetcode.cn/problems/contiguous-array/description/
class Solution {
public:
    int findMaxLength(vector<int>& nums) {
        unordered_map<int ,int>hash;
        int ret=0,sum=0;
        hash[0]=-1;
        for(int i=0;i<nums.size();i++)
        {
            sum+=nums[i]==0?-1:1;
            if(hash.count(sum))
                ret=max(ret,i-hash[sum]);
            //不存在就更新，否则i在前不更新
            else
                hash[sum]=i;
        }
        return ret;
    }
};